package com.zhuoyue.biz.core.command.cmd.common.faa.base;

import com.zhuoyue.biz.core.api.domain.DeviceAndGatewayDO;
import com.zhuoyue.common.constant.DataBase;
import com.zhuoyue.common.utils.CmdUtils;

/**
 * @author Administrator
 */
public class ControlCmd {
    public static String getControlCmd(DeviceAndGatewayDO deviceAndGatewayDO, String cmd10To12) {

        String cmd9 = CmdUtils.getDateLength(cmd10To12);

        String cmd3To12 = DataBase.WRITE +
                DataBase.ONE +
                deviceAndGatewayDO.getGatewayMac() +
                deviceAndGatewayDO.getZigbeeMac() +
                deviceAndGatewayDO.getOdIndex() +
                DataBase.VARIABLE_INDEX +
                cmd9 +
                cmd10To12;


        return baseCmd(cmd3To12);
    }

    public static String myControlCmd(DeviceAndGatewayDO deviceAndGatewayDO, String cmd10To12, String od, String other) {
        String cmd9 = CmdUtils.getDateLength(cmd10To12);

        String cmd3To12 = DataBase.WRITE +
                DataBase.ONE +
                deviceAndGatewayDO.getGatewayMac() +
                deviceAndGatewayDO.getZigbeeMac() +
                od +
                cmd9 +
                cmd10To12;
        return baseCmd(cmd3To12);
    }


    private static String baseCmd(String cmd3To12) {
        String cmd2 = CmdUtils.getDateLength(cmd3To12);

        String cmd13 = CmdUtils.getCmdBodySum(cmd3To12);

        String fullCmd = DataBase.DATA_HEAD +
                cmd2 +
                cmd3To12 +
                cmd13 +
                DataBase.DATA_END;
        return fullCmd;
    }
}
